Skip to content

test: add shared generator conformance suite for codegen backends (#420) - #430

Open
igel-devin-ai wants to merge 27 commits into
java-helpers:mainfrom
igel-devin-ai:test/issue-420-generator-conformance-suite
Open

igel-devin-ai wants to merge 27 commits into
java-helpers:mainfrom
igel-devin-ai:test/issue-420-generator-conformance-suite

Conversation

@igel-devin-ai

@igel-devin-ai igel-devin-ai commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #420.

Adds a backend-neutral conformance suite that every ClassCodeGenerator implementation must pass: Roaster today, the built-in backend (#364) and JavaPoet later. No backend has to duplicate the tests.

  • GeneratorConformanceTest and the TestBackendProvider SPI live in codegen-testing. ServiceLoader finds the providers, creating each one once, and each provider's name appears in the test names.
  • A backend opts in with a provider class and a services file. RoasterTestBackendProvider in codegen-roaster uses the real default formatter profile. Surefire's dependenciesToScan picks the suite up from the codegen-testing jar.
  • 10 fixtures cover fields, methods and constructors, generic bounds, collections/arrays/Optional, nested types, annotations including TYPE_USE, code-template placeholders, static imports, supertype and interfaces, Javadoc, and colliding simple type names (Fields of different types sharing a simple name (e.g. java.util.Date / java.sql.Date) generate uncompilable builder #417). Each fixture checks that javac compiles the output, including the Javadoc fixture, and that the declarations match exactly (text blocks, no fragment or OR asserts).
  • All fixture DTOs are built entirely through the generated *DtoBuilders. No DTO is changed after build().

Found by the stricter asserts: Roaster dropped type-use annotations on field and return types. This is fixed in #434 (issue #433).

Dependencies

This branch contains the commits of #425, #429 (and through it #426, #428, #436) and #434. The diff shrinks to the suite once they are merged.

Tradeoffs (deliberately kept)

Verified: mvn clean verify passes, and GeneratorConformanceTest runs 10 tests in codegen-roaster.

AndreasIgelCC and others added 14 commits November 18, 2026 09:14
…ssue-412-field-name-examples' into test/generator-conformance-suite
…ssue-418-keyword-property-names' into test/generator-conformance-suite
…covery

Introduces GeneratorConformanceTest in codegen-testing: backend-agnostic
contract tests that verify every ClassCodeGenerator emits compilable,
semantically correct Java source for a common set of model fixtures
(fields/methods/ctors, generics, collections, nested types, annotations,
code templates, static imports, colliding type names).

Backends bind via the TestBackendProvider SPI discovered through
ServiceLoader, so each generator module opts in with a provider class and
services file - no test code is duplicated per backend. Parameterized
invocations are named after the provider so failures identify the failing
generator. codegen-roaster registers RoasterTestBackendProvider and scans
the suite from the codegen-testing jar via surefire dependenciesToScan.

This is the acceptance harness needed before adding further generator
implementations (issue java-helpers#366).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shared generator conformance suite for codegen backends

2 participants